﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HRM.DAL.DAO;

namespace HRM.UI.HRManagerUI.Configuration
{
    public partial class CodeConfigure : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetCodePrefix();
        }

        private void GetCodePrefix()
        {
            CodePrefix code = new CodePrefix();
            code = code.GetCodePrefix();
            pCodePrefix.InnerText = code.Prefix + code.Number;
        }

        protected void SaveCodePrefix(object o, EventArgs e)
        {
            CodePrefix code = new CodePrefix();
            code.Prefix = txtCodePrefix.Value;
            code.Number = Convert.ToInt32(txtNumber.Value);
            if (code.SaveCodePrefix(code))
            {
                msgLabel.Text = "Successfylly Generated Code Prefix ";
                GetCodePrefix();
            }
            else
            {
                msgLabel.Text = "Prefix generating failed";
            }
        }
    }
}